package test.circleimport;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class Customer {
    private List<Bill> bills;

    //特定Customer的折扣根据订单数目计算
    public BigDecimal getDiscountAmount() {
        if (bills.size() > 5) {
            return new BigDecimal(0.1);
        } else {
            return new BigDecimal(0.03);
        }
    }

    public void createBill(BigDecimal price) {
        Bill bill = new Bill(this, price);
        if (bills == null) {
            bills = new ArrayList<>();
        }
        bills.add(bill);
    }

    public float totalBill() {
        if (bills == null) return 0f;
        float sum = 0f;
        for (Bill bill : bills) {
            sum += bill.pay().floatValue();
        }
        return sum;
    }

}